package com.bra.ui.adapter;

import com.bra.R;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
/**
 * 选择场地页面预定adapter
 * @author lenovo
 *
 */
public class SelectVenue_advance_adapter extends BaseAdapter {
	private Context context;
	private String[] items;
	private LayoutInflater mInflater;

	public SelectVenue_advance_adapter(Context context, String[] items) {
		this.context = context;
		this.items = items;
		mInflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return items[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.selectvenue_yd_item, null);			
			holder.xzcd_cd_name = (TextView) convertView.findViewById(R.id.xzcd_cd_name);
			holder.dongtai_textview = (LinearLayout) convertView.findViewById(R.id.dongtai_textview);
			for(int i=0;i<items.length;i++){
				LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
						LayoutParams.MATCH_PARENT, 70);
				params.topMargin = 11;
				params.bottomMargin= 12;			
				holder.yuding=new TextView(context);								
				holder.yuding.setGravity(Gravity.CENTER);
				holder.yuding.setText("80¥");
				holder.yuding.setTextColor(context.getResources().getColor(R.color.white));
				holder.yuding.setBackgroundColor(context.getResources().getColor(R.color.color_956700));
				holder.dongtai_textview.addView(holder.yuding, params);
				holder.yuding.setOnClickListener(new OnClickListener() {					
					@Override
					public void onClick(View v) {
						Toast.makeText(context, "请预定", 0).show();						
					}
				});
			}						
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.xzcd_cd_name.setText(items[position]);
		holder.yuding.setText("已预订");
		holder.yuding.setTextColor(context.getResources().getColor(R.color.color_646464));
		holder.yuding.setBackgroundColor(context.getResources().getColor(R.color.color_323232));
		
		return convertView;
	}

	public class ViewHolder {
		public LinearLayout dongtai_textview;
		private TextView xzcd_cd_name;
		private TextView yuding;
	}

}
